package leetcode.code1386;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

//超出内存限制，数组哈希超内存
public class Solution implements IDebug {

	final int two = 0b1111111100;
	final int one1 = 0b111100;
	final int one2 = 0b11110000;
	final int one3 = 0b1111000000;

	public int maxNumberOfFamilies(int n, int[][] reservedSeats) {
		int[] seats = new int[n + 1];
		for (int[] reserved : reservedSeats) {
			int row = reserved[0], no = reserved[1];
			seats[row] |= 1 << no;
		}
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			int row = seats[i];
			if ((row & two) == 0) {
				ans += 2;
			} else if ((row & one1) == 0 || (row & one2) == 0 || (row & one3) == 0) {
				ans += 1;
			}
		}
		return ans;
	}

	@Override
	public void debug1() {
		HelpDebug.compare(4, this.maxNumberOfFamilies(3, HelpDebug.str2array1("[[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]")));

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
